/*
 * @Author: PanZhangOne
 * @Date: 2017-12-15 10:16:53
 * @Last Modified by: PanZhangOne
 * @Last Modified time: 2017-12-16 11:44:28
 */
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const morgan = require('morgan');
const mongoose = require('mongoose');
const passport = require('passport');
const routes = require('./routes');
const config = require('./config');

let port = process.PORT || 3000;

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(passport.initialize()); // 初始化passport模块
app.use(morgan('dev'));

routes(app);

mongoose.Promise = global.Promise;
mongoose.connect(config.database);

app.listen(port, () => {
  console.log('app listening on port : ' + port);
});
